// 购物车相关接口

import httpInstance from "@/utils/http"

// 加入购物车
export const insertCartAPI = ({ goodsId, count }) => {
    return httpInstance({
        url: '/cart',
        method: 'POST',
        data: {
             goodsId: goodsId,
            count,
            selected: false
        }
    })
}

// 获取最新的购物车列表
export const findNewCartListAPI = () => {
    return httpInstance({
        url: '/cart'
    })
}

// 删除购物车
export const delCartAPI = (ids) => {
    return httpInstance({
        url: '/cart',
        method: 'DELETE',
        data: {
            id: ids
        }
    })
}

// 合并购物车
export const mergeCartAPI = (data) => {
    return httpInstance({
        url: '/cart/merge',
        method: 'POST',
        data: data
    })
}

// 更新购物车勾选状态
export const updateCart = (data) => {
    return httpInstance({
        url: "/cart/update",
        method: "POST",
        data
    })
}